home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / rexx / namestruc < prev    next >
Text File  |  1995-03-15  |  772b  |  27 lines

  1. /*rx 
  2.  
  3.  *
  4.  * NAMESTRUC :  part of PasTeX, *must* be in REXX:
  5.  *
  6.  
  7.  This script accepts a filename and returns three lengthes (not
  8. strings, to avoid problems with embedded spaces) corresponding to the
  9. main parts of this filename.
  10.  
  11. Example: RAM:foo/bar/nasty.tar.Z
  12.             ^       ^         ^
  13.     volume     : 4 (RAM:)
  14.     subdirlen: 8 (foo/bar/)        NOTE : The trailing slash is included.
  15.     baselen     : 9 (nasty.tar)    NOTE : if no extension, whole length.
  16. */
  17.  
  18. PARSE ARG fullname
  19. /*fullname = strip(fullname,'L')*/
  20. volume     = INDEX(fullname,":")
  21. subdirlen= LASTPOS("/",SUBSTR(fullname,1+volume))
  22. fileonly = SUBSTR(fullname,volume+1+subdirlen)
  23. baselen  = LASTPOS(".",fileonly)
  24. IF 0 = baselen    THEN baselen = LENGTH(fileonly)
  25.         ELSE baselen = baselen -1
  26. RETURN volume' 'subdirlen' 'baselen
  27.